From: Martin Storsjö Date: Mon, 5 Sep 2022 12:17:56 +0000 (+0300) Subject: slicethread: Limit the automatic number of threads to 16 X-Git-Tag: archive/raspbian/7%8.1-3+rpi1~1^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2^2~1 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/success//%22mailto:kde%40ewsoftware.de/%22/%22http:/www.example.com/cgi/success/%22mailto:kde%40ewsoftware.de/%22?a=commitdiff_plain;h=a6cbc60ddea55fef0f4844b3cee587b1730e9d85;p=ffmpeg.git slicethread: Limit the automatic number of threads to 16 This matches a similar cap on the number of automatic threads in libavcodec/pthread_slice.c. On systems with lots of cores, this fixes a couple fate failures in 32 bit mode on such machines (where spawning a huge number of threads runs out of address space). Signed-off-by: Martin Storsjö Gbp-Pq: Name 0002-slicethread-Limit-the-automatic-number-of-threads-to.patch --- diff --git a/libavutil/slicethread.c b/libavutil/slicethread.c index ea1c9c83..115b0997 100644 --- a/libavutil/slicethread.c +++ b/libavutil/slicethread.c @@ -24,6 +24,8 @@ #include "thread.h" #include "avassert.h" +#define MAX_AUTO_THREADS 16 + #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS typedef struct WorkerContext { @@ -105,7 +107,7 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, if (!nb_threads) { int nb_cpus = av_cpu_count(); if (nb_cpus > 1) - nb_threads = nb_cpus + 1; + nb_threads = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS); else nb_threads = 1; }